package com.icu.controller;

import com.icu.controller.request.user.UserAddRequest;
import com.icu.controller.request.user.UserLoginRequest;
import com.icu.controller.request.user.UserListRequest;
import com.icu.service.IUserService;
import com.icu.util.RUtil;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

/**
 * 用户
 */
@RestController
@RequestMapping("user")
public class UserController {

    @Resource
    private IUserService iUserService;

    /**
     * 添加
     */
    @PostMapping("add")
    public RUtil add(@RequestBody UserAddRequest request) {
        return iUserService.add(request);
    }

    /**
     * 登录
     */
    @PostMapping("login")
    public RUtil login(@RequestBody UserLoginRequest request) {
        return iUserService.login(request);
    }

    /**
     * 列表
     */
    @PostMapping("list")
    public RUtil list(@RequestBody UserListRequest request) {

        Map<String, Object> addressVO = iUserService.list(request);

        return RUtil.success(addressVO);
    }

}